package com.fly.spring.data.core.config;

import javax.sql.DataSource;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.alibaba.druid.pool.DruidDataSource;

import lombok.extern.slf4j.Slf4j;

/**
 * 
 * 数据源管理
 * 
 * @author 00fly
 * @version [版本号, 2020年6月3日]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */
@Slf4j
@Configuration
public class DataSourceConfig
{
    /**
     * 有多少个从库就要配置多少个<br>
     * 如：配置文件中是driver-class-name, 转驼峰命名driverClassName便可以绑定成
     * 
     * @return
     */
    @Bean(name = "read01")
    @ConfigurationProperties(prefix = "mysql.datasource.read01")
    public DataSource readDataSourceOne()
    {
        log.info("-------------------- read01 DataSourceOne init ---------------------");
        return new DruidDataSource();
    }
    
    @Bean(name = "read02")
    @ConfigurationProperties(prefix = "mysql.datasource.read02")
    public DataSource readDataSourceTwo()
    {
        log.info("-------------------- read02 DataSourceTwo init ---------------------");
        return new DruidDataSource();
    }
    
}
